<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
JSJaC Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="JSJaCCookie.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>JSJaC</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>JSJaCCookie.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		OO interface to handle cookies.
 Taken from <a href='http://www.quirksmode.org/js/cookies.html'>http://www.quirksmode.org/js/cookies.html</a>
 Regarding licensing of this code the author states:

 "You may copy, tweak, rewrite, sell or lease any code example on
 this site, with one single exception."

 <BR/><BR/><B>Version: </B>$Revision: 437 $<BR/><BR/><B>Author:</B> Stefan Strigler
 <BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="JSJaCCookie.html">JSJaCCookie</a></b></td>
    <td>Class representing browser cookies for storing small amounts of data
 </td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="JSJaCCookieException.html">JSJaCCookieException</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* Copyright 2003-2006 Peter-Paul Koch
 */</span>

<span class="comment">/**
 * <span class="attrib">@fileoverview</span> OO interface to handle cookies.
 * Taken from {<span class="attrib">@link</span> http://www.quirksmode.org/js/cookies.html
 * http://www.quirksmode.org/js/cookies.html}
 * Regarding licensing of this code the author states:
 *
 * "You may copy, tweak, rewrite, sell or lease any code example on
 * this site, with one single exception."
 *
 * <span class="attrib">@author</span> Stefan Strigler
 * <span class="attrib">@version</span> $Revision: 437 $
 */</span>

<span class="comment">/**
 * Creates a new Cookie
 * <span class="attrib">@class</span> Class representing browser cookies for storing small amounts of data
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {String} name  The name of the value to store
 * <span class="attrib">@param</span> {String} value The value to store
 * <span class="attrib">@param</span> {int}    secs  Number of seconds until cookie expires (may be empty)
 */</span>
<span class="reserved">function</span> JSJaCCookie(name,value,secs)
{
  <span class="reserved">if</span> (window == <span class="reserved">this</span>)
    <span class="reserved">return</span> new JSJaCCookie(name, value, secs);

  <span class="comment">/**
   * This cookie's name
   * <span class="attrib">@type</span> String
   */</span>
  <span class="reserved">this</span>.name = name;
  <span class="comment">/**
   * This cookie's value
   * <span class="attrib">@type</span> String
   */</span>
  <span class="reserved">this</span>.value = value;
  <span class="comment">/**
   * Time in seconds when cookie expires (thus being delete by
   * browser). A value of -1 denotes a session cookie which means that
   * stored data gets lost when browser is being closed. 
   * <span class="attrib">@type</span> int
   */</span>
  <span class="reserved">this</span>.expires = secs;

  <span class="comment">/**
   * Stores this cookie
   */</span>
  <span class="reserved">this</span>.write = <span class="reserved">function</span>() {
    <span class="reserved">if</span> (<span class="reserved">this</span>.secs) {
      var date = new Date();
      date.setTime(date.getTime()+(<span class="reserved">this</span>.secs*1000));
      var expires = <span class="literal">"; expires="</span>+date.toGMTString();
    } <span class="reserved">else</span>
      var expires = <span class="literal">""</span>;
    document.cookie = <span class="reserved">this</span>.getName()+<span class="literal">"="</span>+<span class="reserved">this</span>.getValue()+expires+<span class="literal">"; path=/"</span>;
  };
  <span class="comment">/**
   * Deletes this cookie
   */</span>
  <span class="reserved">this</span>.erase = <span class="reserved">function</span>() {
    var c = new JSJaCCookie(<span class="reserved">this</span>.getName(),<span class="literal">""</span>,-1);
    c.write();
  };

  <span class="comment">/**
   * Gets the name of this cookie
   * <span class="attrib">@return</span> The name
   * <span class="attrib">@type</span> String
   */</span>
  <span class="reserved">this</span>.getName = <span class="reserved">function</span>() {
    <span class="reserved">return</span> <span class="reserved">this</span>.name;
  };
 
  <span class="comment">/**
   * Sets the name of this cookie
   * <span class="attrib">@param</span> {String} name The name for this cookie
   * <span class="attrib">@return</span> This cookie
   * <span class="attrib">@type</span> Cookie
   */</span>
  <span class="reserved">this</span>.setName = <span class="reserved">function</span>(name) {
    <span class="reserved">this</span>.name = name;
    <span class="reserved">return</span> <span class="reserved">this</span>;
  };

  <span class="comment">/**
   * Gets the value of this cookie
   * <span class="attrib">@return</span> The value
   * <span class="attrib">@type</span> String
   */</span>
  <span class="reserved">this</span>.getValue = <span class="reserved">function</span>() {
    <span class="reserved">return</span> <span class="reserved">this</span>.value;
  };
 
  <span class="comment">/**
   * Sets the value of this cookie
   * <span class="attrib">@param</span> {String} value The value for this cookie
   * <span class="attrib">@return</span> This cookie
   * <span class="attrib">@type</span> Cookie
   */</span>
  <span class="reserved">this</span>.setValue = <span class="reserved">function</span>(value) {
    <span class="reserved">this</span>.value = value;
    <span class="reserved">return</span> <span class="reserved">this</span>;
  };
}

<span class="comment">/**
 * Reads the value for given &lt;code&gt;name&lt;/code&gt; from cookies and return new
 * &lt;code&gt;Cookie&lt;/code&gt; object
 * <span class="attrib">@param</span> {String} name The name of the cookie to read
 * <span class="attrib">@return</span> A cookie object of the given name
 * <span class="attrib">@type</span> Cookie
 * <span class="attrib">@throws</span> CookieException when cookie with given name could not be found
 */</span>
JSJaCCookie.read = <span class="reserved">function</span>(name) {
  var nameEQ = name + <span class="literal">"="</span>;
  var ca = document.cookie.split(<span class="literal">';'</span>);
  <span class="reserved">for</span>(var i=0;i &lt; ca.length;i++) {
    var c = ca[i];
    <span class="reserved">while</span> (c.charAt(0)==<span class="literal">' '</span>) c = c.substring(1,c.length);
    <span class="reserved">if</span> (c.indexOf(nameEQ) == 0) <span class="reserved">return</span> new JSJaCCookie(name, c.substring(nameEQ.length,c.length));
  }
  throw new JSJaCCookieException(<span class="literal">"Cookie not found"</span>);
};

<span class="comment">/**
 * Reads the value for given &lt;code&gt;name&lt;/code&gt; from cookies and returns
 * its valued new
 * <span class="attrib">@param</span> {String} name The name of the cookie to read
 * <span class="attrib">@return</span> The value of the cookie read
 * <span class="attrib">@type</span> String
 * <span class="attrib">@throws</span> CookieException when cookie with given name could not be found
 */</span>
JSJaCCookie.get = <span class="reserved">function</span>(name) {
  <span class="reserved">return</span> JSJaCCookie.read(name).getValue();
};

<span class="comment">/**
 * Deletes cookie with given &lt;code&gt;name&lt;/code&gt;
 * <span class="attrib">@param</span> {String} name The name of the cookie to delete
 * <span class="attrib">@throws</span> CookieException when cookie with given name could not be found
 */</span>
JSJaCCookie.remove = <span class="reserved">function</span>(name) {
  JSJaCCookie.read(name).erase();
};

<span class="comment">/**
 * Some exception denoted to dealing with cookies
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {String} msg The message to pass to the exception
 */</span>
<span class="reserved">function</span> JSJaCCookieException(msg) {
  <span class="reserved">this</span>.message = msg;
  <span class="reserved">this</span>.name = <span class="literal">"CookieException"</span>;
}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>JSJaC</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Tue Feb 12 18:46:55 2008</div>
</body>
</html>
